package ch.unisi.inf.editor;

import java.awt.Color;
import ch.unisi.inf.engine.Image;
/**
 * inverts each RGB value of each pixel with 255-RGB  
 * 
 * @author matthias.eberli@lu.unisi.ch 
 */
public class InvertColorFilter extends Filter
{
    
    public InvertColorFilter(final String name)
    {
        super(name);
    }

    public void apply(final Image image)
    {
        final int height = image.getHeight();
        final int width = image.getWidth();
        for(int y = 0; y < height; y++) {
            for(int x = 0; x < width; x++) {
                Color pixel = image.getPixel(x, y);
                image.setPixel(x, y, new Color(255-pixel.getRed(), 255-pixel.getGreen(), 255-pixel.getBlue()));
            }
        }
    }
}